    define("pages/jls_Swdj/main", [
            "../../plugins/easyui/jquery-easyui-1.5.1/jquery.easyui.min",
            "../../plugins/easyui/jquery-easyui-1.5.1/easyloader",
            "../../plugins/artTemplate/artTemplate",
            "../../common/tools",
            "../../common/componts",
            "../../common/kss",
            "../../pages/jls_Swdj/form",
            "../../pages/jls_Jbxx/JbxxShowHide.html.js",
            "../../pages/jls_Swdj/SwdjShowHide.html.js"
        ],
        function(require) {
            var comonts=require("../../common/componts");
            var swdjForm=require("../../pages/jls_Swdj/form");
            var tmp=require("../../pages/jls_Jbxx/JbxxShowHide.html");
            var tmpSwdj=require("../../pages/jls_Swdj/SwdjShowHide.html");
            var kss=require("../../common/kss");
            var ryjbxxId="jbxxId";
            var swdjId="swdjId";
            var swdj="swdj";
            var selectid;
            var id;
            var jbxx="jbxx";

            var tableInit=function(){
                kss.initJbxxTable(ryjbxxId,{
                    singleSelect:true,
                    url:'/jls_jbxx/jbxxList',
                    detailFormatter : function(index, rowData) {
                        return '<table  style="height:60px;width:100%"><tr><td>户籍地详细地址：'
                            + (rowData.hjszd == null ? ""
                                : rowData.hjszd)
                            + '</td></tr><tr><td>现住地详细地址:'
                            + (rowData.xzd == null ? "" : rowData.xzd)
                            + '</td></tr><tr><td>办案单位:'
                            + (rowData.badw == null ? "" : rowData.badw)
                            + '</td></tr><tr><td>简要案情:'
                            + (rowData.aq == null ? "" : rowData.aq)
                            + '</td></tr></table>'
                    },
                    onDblClickRow:function(rowIndex, rowData){
                        if (rowData.rybh != undefined) {
                            $("input[name='ryRadio']")[rowIndex].checked = true;
                            $("#"+ryjbxxId).datagrid("selectRow", rowIndex);
                            var jbxx=$("#"+ryjbxxId).datagrid('getSelected');
                            swdjForm.show(jbxx,{},refreshTable);

                            $('input').next().find('input[type=text]').css('background-color','#EBEBE4');
                            var myDate = new Date();
                            var str=myDate.toLocaleTimeString();
                        }
                    },
                    onClickRow:function(rowIndex, rowData){
                        if(selectid!=rowData.id){
                            $("input[name='ryRadio']")[rowIndex].checked = true;
                            selectid=rowData.id;
                        }else{
                            $("#"+ryjbxxId).datagrid("unselectRow",rowIndex);
                            $("input[name='ryRadio']")[rowIndex].checked = false;
                            $('#'+ryjbxxId).datagrid('clearSelections');
                            selectid="";
                        }
                    },
                    onSelect:function(rowIndex, rowData){
                        var jbxx = $('#'+ryjbxxId).datagrid('getSelected');
                        var flag = $("input[name='ryRadio']")[rowIndex].checked;
                        if(jbxx && !flag){
                            var rybh = jbxx.rybh;
                            $('#'+swdjId).datagrid('loadData', { total: 0, rows: [] });
                            if (rybh != undefined) {
                                var opts = $("#"+swdjId).datagrid("options");
                                $("#"+swdjId).datagrid("clearSelections");
                                $('#'+swdjId).datagrid('load',{
                                    'rybh': rybh,
                                });
                            }
                        }else {
                            $('#'+swdjId).datagrid('loadData', { total: 0, rows: [] });
                        }
                    },
                    rightmenu:function(){
                    }

                });
                comonts.initTable(swdjId,{
                    title: '死亡登记',
                    url:"/jls_swdj/swdjList",
                    columns:[                    	
                        /*{field: 'id',title: '',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="idRadio" id="idRadio"' + rowIndex + 'value="' + rowData.id + '" />';}},
                        {field: 'rybh',title: '人员编号',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="rybhRadio" id="rybhRadio"' + rowIndex + 'value="' + rowData.rybh + '" />';}},
                        {field: 'swsj',title: '死亡时间',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="swsjRadio" id="swsjRadio"' + rowIndex + 'value="' + rowData.swsj + '" />';}},
                        {field: 'swdd',title: '死亡地点',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="swddRadio" id="swddRadio"' + rowIndex + 'value="' + rowData.swdd + '" />';}},
                        {field: 'swyy',title: '死亡原因',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="swyyRadio" id="swyyRadio"' + rowIndex + 'value="' + rowData.swyy + '" />';}},
                        {field: 'clqk',title: '处理情况',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="clqkRadio" id="clqkRadio"' + rowIndex + 'value="' + rowData.clqk + '" />';}},
                       // {field: 'scbz',title: 'scbz',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="scbzRadio" id="scbzRadio"' + rowIndex + 'value="' + rowData.scbz + '" />';}},
                        {field: 'swlx',title: '死亡录像',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="swlxRadio" id="swlxRadio"' + rowIndex + 'value="' + rowData.swlx + '" />';}},
                        {field: 'operator',title: '操作员',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="operatorRadio" id="operatorRadio"' + rowIndex + 'value="' + rowData.operator + '" />';}},
                        {field: 'createtime',title: '创建时间',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="createtimeRadio" id="createtimeRadio"' + rowIndex + 'value="' + rowData.createtime + '" />';}},
                        {field: 'state',title: '状态',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="stateRadio" id="stateRadio"' + rowIndex + 'value="' + rowData.state + '" />';}},
                        {field: 'jsbh',title: '监室编号',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="jsbhRadio" id="jsbhRadio"' + rowIndex + 'value="' + rowData.jsbh + '" />';}},
                       // {field: 'sjzlJsbz',title: 'sjzlJsbz',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="sjzlJsbzRadio" id="sjzlJsbzRadio"' + rowIndex + 'value="' + rowData.sjzlJsbz + '" />';}},
                        {field: 'savetime',title: '保存时间',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="savetimeRadio" id="savetimeRadio"' + rowIndex + 'value="' + rowData.savetime + '" />';}},
                        {field: 'saveuser',title: '保存用户',formatter: function(value, rowData, rowIndex){return '<input type="radio" name="saveuserRadio" id="saveuserRadio"' + rowIndex + 'value="' + rowData.saveuser + '" />';}},*/

                        {
                            field : 'id',
                            width : 150,
                            title:'',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.id== null ? "" : row.id)+'</span>'
                            }},
                        {
                            field : 'rybh',
                            width : 150,
                            title:'人员编号',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.rybh== null ? "" : row.rybh)+'</span>'
                            }},
                        {
                            field : 'swsj',
                            width : 150,
                            title:'死亡时间',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.swsj== null ? "" : row.swsj)+'</span>'
                            }},
                        {
                            field : 'swdd',
                            width : 150,
                            title:'死亡地点',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.swdd== null ? "" : row.swdd)+'</span>'
                            }},
                        {
                            field : 'swyy',
                            width : 150,
                            title:'死亡原因',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.swyy== null ? "" : row.swyy)+'</span>'
                            }},
                        {
                            field : 'clqk',
                            width : 150,
                            title:'处理情况',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.clqk== null ? "" : row.clqk)+'</span>'
                            }},
                        {
                            field : 'swlx',
                            width : 150,
                            title:'死亡录像',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.swlx== null ? "" : row.swlx)+'</span>'
                            }},
                        {
                            field : 'operator',
                            width : 150,
                            title:'操作员',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.swdd== null ? "" : row.swdd)+'</span>'
                            }},
                        {
                            field : 'createtime',
                            width : 150,
                            title:'创建时间',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.createtime== null ? "" : row.createtime)+'</span>'
                            }},
                        {
                            field : 'state',
                            width : 150,
                            title:'状态',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.state== null ? "" : row.state)+'</span>'
                            }},
                        {
                            field : 'jsbh',
                            width : 150,
                            title:'监室编号',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.jsbh== null ? "" : row.jsbh)+'</span>'
                            }},
                        {
                            field : 'savetime',
                            width : 150,
                            title:'保存时间',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.savetime== null ? "" : row.savetime)+'</span>'
                            }},
                        {
                            field : 'saveuser',
                            width : 150,
                            title:'保存用户',
                            sortable:'true',
                            formatter: function(value,row,index){
                                return '<span title='+value+'>'+(row.saveuser== null ? "" : row.saveuser)+'</span>'
                            }},


                        ],
                    detailFormatter:function(index,rowData){
                        return ;
                    },
                    onClickRow:function(rowIndex, rowData){
                        if(id!=rowData.id){
                            $("input[name='swdjRadio']")[rowIndex].checked = true;
                            $('#'+swdjId).datagrid("selectRow", rowIndex);
                            id=rowData.id;
                        }else if(id==rowData.id){
                            $('#'+swdjId).datagrid("unselectRow",rowIndex);
                            $("input[name='swdjRadio']")[rowIndex].checked = false;
                            id="";
                        }
                    },
                    //双击事件
                    onDblClickRow:function(rowIndex, rowData){
                        $("input[name='swdjRadio']")[rowIndex].checked = true;
                        $('#'+swdjId).datagrid("selectRow", rowIndex);
                        id=rowData.id;
                        var jbxx = $('#jbxxId').datagrid('getSelected');
                        swdjForm.show(jbxx,rowData,refreshTable);
                    },
                });
                $('#'+swdjId).datagrid('resize',{
                    height:($(window).height() -280)
                });
            }
            var findSwdj=function(){
                var val = $("#jqjsTree").tree('getSelected');
                var s_rybh = $("#s_rybh").textbox('getValue');
                var s_xm = $("#s_xm").textbox('getValue');
                //人员状态,单选框
                var opts = $('#'+ryjbxxId).datagrid("options");
                opts.url = "/jls_jbxx/jbxxList";
                $('#'+ryjbxxId).datagrid('clearSelections');
                $('#'+ryjbxxId).datagrid('load',{
                	'xm':s_xm,
                    'rybh':s_rybh,
                });
            }
            var initJsTree=function(){
                kss.initJsTree("jqjsTree","jbxxId",{});
            }
            var bindAction=function(){
                //查看
                $("#swdj_search").on("click",function(){
                    findSwdj();
                });
                //添加
                $("#swdj_add").on("click",function(){
                    var ryjbxx=$("#"+ryjbxxId).datagrid('getSelected');
                    if(ryjbxx){
                        swdjForm.show(ryjbxx,{},refreshTable);
                    }else{
                        $.messager.alert("提示","请选择要新增的记录!","info");
                    }
                });
                //修改
                $("#swdj_update").on("click",function(){
                    var ryjbxx=$("#"+ryjbxxId).datagrid('getSelected');
                    var swdj=$("#"+swdjId).datagrid('getSelected');
                    if(ryjbxx){
                        swdjForm.show(refreshTable,{});
                        $('#rybhId').next().find('input[type=text]').css('background-color','#ebebe4');
                        $('#ryxmId').next().find('input[type=text]').css('background-color','#ebebe4');
                        $('#jshId').next().find('input[type=text]').css('background-color','#ebebe4');
                    }else{
                        $.messager.alert("提示","请选择要修改的记录!","info");
                    }
                });
                //删除
               $("#swdj_delete").on("click",function(){
                    var ryjbxx=$("#"+ryjbxxId).datagrid('getSelected');
                    if(ryjbxx){
                        $.messager.confirm("确认删除","确定要删除所选中的记录吗?");
                    }else{
                        $.messager.alert("提示","请选择要修改的记录!","info");
                    }
                    });

                $(window).keydown(function(event) {
                    if (event.keyCode == 13) {
                        findswdj();
                    }
                });
                comonts.ShowHide(jbxx,tmp);
                comonts.ShowHide(swdj,tmpSwdj);
                $("#swdj_print").on("click",function(){
                    var label="jls_swdj";
                    var name="jls_swdj";
                    var rybh=$("#"+ryjbxxId).datagrid('getSelected').rybh;
                    var url=comonts.getReportUrl(true,label,name,'rybh%3d'+rybh);
                    console.info(url);
                    addTab("Swdj",url);
                });

            }
            var refreshTable=function(data){
                $('#'+swdjId).datagrid('reload',{rybh:$('#'+ryjbxxId).datagrid('getSelected').rybh});
            }


            var initView=function(){
                tableInit();
                bindAction();
                initJsTree();

            }


            initView();
        });
